﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="AadressOtsing", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(AadressOtsing))]
    public class AadressOtsingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAadressOtsing clazz;
        
        public AadressOtsingSerializer(IAadressOtsing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.Aadresskood!=null) {
                Writer.WriteStartElement("Aadresskood");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Aadresskood))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AadressTekst!=null) {
                Writer.WriteStartElement("AadressTekst");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AadressTekst))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.RiikKL!=null) {
                Writer.WriteStartElement("RiikKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.RiikKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MaakondKL!=null) {
                Writer.WriteStartElement("MaakondKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.MaakondKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LinnValdKL!=null) {
                Writer.WriteStartElement("LinnValdKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.LinnValdKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AlevKylaLinnaosaKL!=null) {
                Writer.WriteStartElement("AlevKylaLinnaosaKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.AlevKylaLinnaosaKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Tanav!=null) {
                Writer.WriteStartElement("Tanav");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Tanav))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MajaKrunt!=null) {
                Writer.WriteStartElement("MajaKrunt");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MajaKrunt))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.RuumNimetus!=null) {
                Writer.WriteStartElement("RuumNimetus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.RuumNimetus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KooperatiivKL!=null) {
                Writer.WriteStartElement("KooperatiivKL");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "long");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdLong(((long)(clazz.KooperatiivKL))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PunktiXKoordinaat!=null) {
                Writer.WriteStartElement("PunktiXKoordinaat");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PunktiXKoordinaat))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.PunktiYKoordinaat!=null) {
                Writer.WriteStartElement("PunktiYKoordinaat");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PunktiYKoordinaat))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kirjeldus!=null) {
                Writer.WriteStartElement("Kirjeldus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kirjeldus))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="Aadresskood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Aadresskood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Aadresskood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AadressTekst") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AadressTekst = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AadressTekst")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="RiikKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AadressOtsing>RiikKL");
                }
                clazz.RiikKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("RiikKL")).Value;
            }
            if (Reader.LocalName=="MaakondKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AadressOtsing>MaakondKL");
                }
                clazz.MaakondKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("MaakondKL")).Value;
            }
            if (Reader.LocalName=="LinnValdKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AadressOtsing>LinnValdKL");
                }
                clazz.LinnValdKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("LinnValdKL")).Value;
            }
            if (Reader.LocalName=="AlevKylaLinnaosaKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AadressOtsing>AlevKylaLinnaosaKL");
                }
                clazz.AlevKylaLinnaosaKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("AlevKylaLinnaosaKL")).Value;
            }
            if (Reader.LocalName=="Tanav") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Tanav = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Tanav")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MajaKrunt") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MajaKrunt = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MajaKrunt")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="RuumNimetus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.RuumNimetus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("RuumNimetus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="KooperatiivKL") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>AadressOtsing>KooperatiivKL");
                }
                clazz.KooperatiivKL = new global::Xtee.Core.Schema.XsdLong(Reader.ReadElementString("KooperatiivKL")).Value;
            }
            if (Reader.LocalName=="PunktiXKoordinaat") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PunktiXKoordinaat = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("PunktiXKoordinaat")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="PunktiYKoordinaat") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.PunktiYKoordinaat = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("PunktiYKoordinaat")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kirjeldus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kirjeldus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kirjeldus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
